<template>
	<view class="w100 bg-white pb-30" style="border-radius: 10rpx 10rpx 0 0;">
		<view class="flex plr-36 pt-30 ">
			<view class="size-36 bold">
				订单完成
			</view>
		</view>
		<view class="plr-36 pb-20 mt-10 bb">
			订单已完成，请前往支付并评价
		</view>
		<view class="plr-36 pt-30 flex1 flex-middle">
			<u-icon name="clock" size="40" color="#999"></u-icon>
			<!-- <text class="ml-20">{{info.createtime|formatDate(1)}}</text> -->
			<text class="ml-20">2021-05-05 14:30</text>
		</view>
		<view class="plr-36 pt-30 flex1 flex-middle">
			<view style="width: 26rpx;height: 26rpx;background: #29BB77;border-radius: 50%;"></view>
			<text class="ml-20">二七广场</text>
		</view>
		<view class="plr-36 pt-30 flex1 flex-middle">
			<view style="width: 26rpx;height: 26rpx;background: #FFAE00;border-radius: 50%;"></view>
			<text class="ml-20">百货大楼</text>
		</view>
		<view class=" mt-50 bg-blue white text-center size-32 u-btn--primary"
			style="height: 96rpx;line-height: 96rpx;border-radius: 20rpx;" @click="submit">
			去支付
		</view>
	</view>
</template>

<script>
	export default {
		props: ['info', "huoyun", 'refund_id'], //-1取消
		data() {
			return {
				value: ''
			}
		},
		methods: {
			toRefund() {
				console.log(this.info);
				uni.navigateTo({
					url: '/pages/huoyun/refund-detail?id=' + this.refund_id
				})
			},
			submit() {
				setTimeout(()=>{
					uni.redirectTo({
						url:'../../pages/home/evaluate'
					})
				},500)
				// let _this = this
				// //微信支付
				// // #ifdef MP-WEIXIN
				// uni.login({
				// 	provider: 'weixin',
				// 	success: function(loginRes) {
				// 		console.log(loginRes.code);
				// 		// _this.pay(loginRes.code)
				// 	}
				// })
				// // #endif
				// // #ifndef MP-WEIXIN
				// this.pay()
				// // #endif
			},
			pay(code) {
				this.$http(this.info.sf_type ? '/addons/ddrive/sforder/driver_pay' : '/addons/ddrive/order/driver_pay', {
					order_id: this.info.id,
					coupon_id: this.coupon.id || '',
					// #ifdef APP-PLUS
					type: this.value == '1' ? 'alipay' : 'user_wechat',
					method: 'app'
					// #endif
					// #ifdef MP-WEIXIN
					type: 'mini_wechat',
					method: 'miniapp',
					code: code,
					// #endif
				}, "POST").then(data => {
					console.log(data);
					this.$store.dispatch('updateUserInfo')
					let _this = this
					//data返回参数
					//{
					//	appid: "wxd5cdb23fa8a8a8a4"
					//	noncestr: "ElHzMeZUqs676yRK"
					//	package: "Sign=WXPay"
					//	partnerid: "1601210852"
					//	prepayid: "wx271544341817098433edb8b12397d20000"
					//	sign: "5E26B16FE8B6995D333F09A44A5C7EC3"
					//	timestamp: "1603784674"
					//}
					// #ifdef APP-PLUS
					uni.requestPayment({
						provider: this.value == '1' ? 'alipay' : 'wxpay',
						orderInfo: data, //微信、支付宝订单数据
						success: function(res) {
							console.log('success:' + JSON.stringify(res));
							uni.showToast({
								title: '支付成功'
							})
							_this.close()
							_this.$emit('update')
						},
						fail: function(err) {
							console.log('fail:' + JSON.stringify(err));
						}
					});
					// #endif
					// #ifdef MP-WEIXIN
					uni.requestPayment({
						provider: 'wxpay',
						timeStamp: data.timeStamp,
						nonceStr: data.nonceStr,
						package: data.package,
						signType: 'MD5',
						paySign: data.paySign,
						success: function(res) {
							uni.showToast({
								title: '支付成功'
							})
							_this.close()
							_this.$emit('update')
							_this.$store.commit('exitEwm')
						},
						fail: function(err) {
							console.log('fail:' + JSON.stringify(err));
						}
					});
					// #endif
				})
			},
		}
	}
</script>

<style lang="scss">
	/deep/.u-primary-hover {
		background-color: $blue !important;
	}

	/deep/.u-radio {
		display: flex;
		flex-direction: row-reverse;
	}

	/deep/.u-radio__label {
		margin-left: 0;
		margin-right: 0;
	}

	.img {
		image {
			width: 40rpx;
			height: 40rpx;
		}
	}
</style>
